home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
util
/
sys
/
SerPrefs.lha
/
SerPrefs
/
Developers
/
modules
/
prefs
/
serial.e
next >
Wrap
Text File
|
1997-11-25
|
7KB
|
203 lines
/* $VER: serial.e 42.2 (4.10.1997) #ESOURCE © Msi Software
**
** File format for new (v1) serial preferences
**
** Original (v38) structure was 33 in size, the new is 34 in size.
**
** (C) Copyright 1997 Msi Software.
** All Rights Reserved
*/
OPT MODULE
OPT EXPORT
OPT PREPROCESS /* Make shure you use the same option in your source */
CONST ID_SERL=$5345524C, /* Serial settings ID */
ID_SERN=$5345524E /* Serial name ID */
OBJECT serialprefs
reserved[3]:ARRAY OF LONG /* System Reserved */
unit0map:LONG /* default unit */
baudrate:LONG /* baud to be used */
inputbuffer:LONG /* buffer size to be used (in bytes) */
outputbuffer:LONG /* buffer size to be used (in bytes) */
inputhandshake:CHAR /* see handshake constants */
outputhandshake:CHAR /* see handshake constants */
parity:CHAR /* see parity constants */
bitsperchar:CHAR /* data bits */
stopbits:CHAR /* stop bits */
/* The original "C=" object ends here! */
sharedmode:CHAR /* see shared constants */
ENDOBJECT /* SIZE 34, original was 33 */
/* "sername" Full pathname of device, (0 terminated) */
/* Stored in a separate IFF "SERN" CHUNK after the SERL chunk */
CONST PARITY_NONE=0,
PARITY_EVEN=1,
PARITY_ODD=2,
PARITY_MARK=3,
PARITY_SPACE=4,
HSHAKE_XON=0,
HSHAKE_RTS=1,
HSHAKE_NONE=2,
/* End of original "C=" constants! */
SHARED_NONE=0,
SHARED_ON=1
/* some nice strings to be used with AmigaE preprocessing */
#define DEFSERNAME 'DEVS:serial.device'
#define DEFSERENV 'ENV:Sys/serial.prefs'
#define DEFSERENVARC 'ENVARC:Sys/serial.prefs'
#define DEFSERPREFICON 'ENV:Sys/def_prefs'
#define DEFSERPREFTOOL 'Sys:Prefs/Serial'
/* serial.prefs versions
SerPrefs uses the type entry in the PRHD chunk (prefheader)
to let you know that the prefs are different.
(INCLUDES:prefs/prefhdr.h)
The original serial.prefs keep that value 0,
and serial.prefs v42.x keep this value 1.
When the next serial.prefs is defined it will
have value 2 or something like that.
So check the type in the PRHD chunk,
since this is much better and safer than checking the size
of the SERL chunk :-)
If you find i.e 0 as the type in PRHD,
then DO NOT try to use any data after the stop bit,
since this most likely is an old serial.prefs.
This way old programs can use new prefs without problems,
(the old Serial programs will ignore any extra data).
And new programs is able to use old prefs,
with no need for the user to convert the prefs.
A nice way to read the serial.prefs is:
1. get prefsheader.version
2. get prefsheader.type
3. get prefsheader.flags
4. if version is not 0 then report to user and abort
5. currently just ignore the flags
6. check SERL chunk lenght (do not use lenght for version/type checking)
7. process first part (v0)
8. if type was 1 process second part (v1)
9. (when v2 etc is used you would process it here and so on)
10. get SERN and process filename if any (perhaps get device version)
To avoid problems, always check that the lenght is "larger than 32",
do not check if it is 34 or 33 since even though it is 33
the bug cause it to become 34.
For v1 you should check the SERL lenght if it is larger than 34 or not,
if a v1 serial.prefs SERL chunk is less than 34, it is corrupt.
Doing this allow us to use the same code for v0
for v1 and v2 prefs, instead of separate v0,v1 ad v2 routines.
SerPrefs v2.1 and later use this method,
resulting in much less code needed :-)
If you wonder why I used prefheader.type instead of prefheader.version,
it is because when using prefheader.version,
IPrefs complain about being unable to read the prefs,
and since serial.prefs has not really changed,
but rather been extended this is silly since serial.prefs
no longer is backwards compatible.
But since there is no revision to use I had to use type instead,
after all v1 is a different prefs type than v0 :-)
So by using type IPrefs is able to read the prefs as v0 prefs,
thus baud etc is used correctly (at least they should).
*/
/* sharedmode
Due to a bug in the C= serial.prefs,
the SERL chunk pad is counted into the SERL chunk lenght.
To take advantage of this I used this "hidden" byte to
toggle sharedmode, please note that neither IPrefs or original Serial
is aware of this and will just ignore it (thinking it's a pad :-)
Since the IFF specs say a pad should always be zero,
we can count on it being correct (not corrupted by Serial prefs utils).
But since it is counted as a part of the chunk,
according to the IFF specs it is not a pad :-)
So we can count on the IFF system to not mess with it either,
so the result is a unused byte everyone ignores :-)
I decided the first best thing to add to serial.prefs was Shared Mode,
and what better place to start than the unused byte?
*/
/* bitsperchar
Common "Data Bits" (Bits Per Char):
5, 6, 7, 8.
8 is most used, and also the default value.
Additional bits (for future use):
16, 32.
These are not used (hardly any hardware support >8 bits,
but to avoid updating of software,
these should be supported in preparation of new serial hardware.
*/
/* stopbits
Common "Stop Bits":
0, 1, 2.
1 is most used, and also the default.
*/
/* inputbuffer/outputbuffer
No real limits, can be up to the maximum 32bit value.
Or down to 64 bytes, the C= docs etc,
advise this value to be a multiple of 64.
Advised default is 4096 bytes, advised minimum is 512 bytes.
For simplicity use x*2, x/2 based values.
Like 512, 1024, 2048, 4096 etc, so the user don't have to
flip thru a bunch of numbers forever, or have to type it :-)
It's easier to keep the value a multiple of 64 bytes also.
*/
/* baudrate
No common or advised, this vary alot on modem/hardware/connection etc.
Can be odd/even, but using well know rates are HIGHLY ADVISED.
This to avoid confusing users as well as software/hardware :-)
Here is a list of rates (as used in Msi Software's SerPrefs):
75
110
150
300
600
1200
2400
4800
7200
9600 /* fax rate, default (old) */
14400
16800
19200 /* 14.4 rate, fax rate, common default */
21600
24000
26400
28800
31200
31250 /* MIDI rate, max rate on older software/Amiga */
33600
38400 /* 28.8/33.6 rate, advised default due to many 28.8 modems */
57600 /* Max (reliable) internal serial, can be used as 33.6 rate */
64000
62400
64800
65535
65536
76800
115200 /* Squirrel Surf (SCSI w/serial for A1200) can go this high */
230400
345600
460800
576000
614400
691200
806400
921600 (please note that the SerPrefs program may support even more)
*/
/* Roger Hågensen <emsai@online.no>
Msi Software - 5th July 1997
http://www.sn.no/~msi/index.htm
*/